﻿@{
    ViewBag.Title = "Welcome " + User.Identity.Name;
}

<div class="content-wrapper">
    <hgroup id="name-and-slogan">
        <h1>Telerik Connect</h1>
        <h2>The place where ninjas meet!</h2>
    </hgroup>

    <section id="latest-updates">
        <h2>Latest updates</h2>
        <h5>Follow more people to see their updates</h5>
        <div id="listView"></div>
    </section>

    <h2>PostUpdate</h2>

    @using (Html.BeginForm("PostUpdate", "Updates", FormMethod.Post))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)
        <label for="content">Post an update: </label>
        <input type="text" class="k-input" name="content" />

        <input type="submit" class="k-button" />
    }

    <h2>Users</h2>

    <div>
        <h3>Search</h3>
        @using (Html.BeginForm("SearchUsersWith", "Account", FormMethod.Post))
        {
            @Html.AntiForgeryToken()
            <label for="searchToken">Find user with:</label>
            <input type="text" class="k-input" name="searchToken" />
            <input type="submit" class="k-button" value="Search" />
        }

        <h3>Starting with:</h3>
        <div> | 
            @for (char c = 'A'; c <= 'Z'; c++)
            {
                <a href="~/Account/UsersByFirstLetter?firstLetter=@c" class="k-button">@c</a>@: |
            }
        </div>

        <script type="text/x-kendo-tmpl" id="template">
        <article class="clear-fix">
            <a href="/Account/Profile/#:Author#" title="#:Author#"><img src="#:Avatar#" alt="#:Author#" class="thumb-img" /></a>
            <p class="content">#:Content#</p>
        <p class="post-by">By: <a class="k-button" href="/Account/Profile/#:Author#" >#:FirstName# #:LastName#</a><p>
        </article>
        </script>

        <script>
            $(document).ready(function () {
                var dataSource = new kendo.data.DataSource({
                    transport: {
                        read: {
                            url: '@Url.Content("~/Updates/GetUpdates/0")', // the remote service url - Twitter API v1.1
                            contentType: "application/json; charset=utf-8",
                            type: "GET",
                            dataType: "json"
                        }
                    },
                    schema: {
                        data: function (data) {
                            return data;
                        }
                    }
                });

                $("#pager").kendoPager({
                    dataSource: dataSource
                });

                $("#listView").kendoListView({
                    dataSource: dataSource,
                    template: kendo.template($("#template").html())
                });
            });
        </script>
    </div>
</div>
